package src.main.java.org.stream;

import java.util.*;
import java.util.stream.Stream;

/*
* Stream流的常用方法
* */
public class Test1 {
    public static void main(String[] args) {
        //获取stream流,List集合
        ArrayList<String> names = new ArrayList<>();
        Collections.addAll(names,"张三丰","张无忌","周芷若","赵敏","张强");
        Stream<String> stream = names.stream();

        //获取stream流,Set集合
        HashSet<String> set = new HashSet<>();
        Collections.addAll(set,"刘德华","张曼玉","蜘蛛精","玛德","马冬梅");
        Stream<String> stream1 = set.stream();
        stream1.filter(s->s.contains("德")).forEach(s-> System.out.println(s));

        //获取stream流,Map集合
        HashMap<String,Double> map = new HashMap<>();
        map.put("古力娜扎",172.3);
        map.put("迪丽热巴",171.3);
        map.put("易烊千玺",173.3);
        map.put("斯琴高娃",175.3);
        /*Set<String> strings = map.keySet();
        Stream<String> stream2 = strings.stream();

        Collection<Double> values = map.values();
        Stream<Double> stream3 = values.stream();*/

        Set<Map.Entry<String, Double>> entries = map.entrySet();
        Stream<Map.Entry<String, Double>> stream2 = entries.stream();
        stream2.filter(e->e.getKey().contains("巴")).forEach(e-> System.out.println(e.getKey()+"==="+e.getValue()));

        //获取stream流,数组
        String[] name2 = {"张三丰","张无忌","周芷若","赵敏","张强"};
        Stream<String> stream3 = Arrays.stream(name2);
        Stream<String> name21 = Stream.of(name2);

    }
}
